﻿using Galoap;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;
using System.Collections.Generic;
using System.Linq;

namespace Tests
{
    
    
    /// <summary>
    ///This is a test class for GameTest and is intended
    ///to contain all GameTest Unit Tests
    ///</summary>
    [TestClass()]
    public class GameTest
    {


        private TestContext testContextInstance;

        /// <summary>
        ///Gets or sets the test context which provides
        ///information about and functionality for the current test run.
        ///</summary>
        public TestContext TestContext
        {
            get
            {
                return testContextInstance;
            }
            set
            {
                testContextInstance = value;
            }
        }

        #region Additional test attributes
        // 
        //You can use the following additional attributes as you write your tests:
        //
        //Use ClassInitialize to run code before running the first test in the class
        //[ClassInitialize()]
        //public static void MyClassInitialize(TestContext testContext)
        //{
        //}
        //
        //Use ClassCleanup to run code after all tests in a class have run
        //[ClassCleanup()]
        //public static void MyClassCleanup()
        //{
        //}
        //
        //Use TestInitialize to run code before running each test
        //[TestInitialize()]
        //public void MyTestInitialize()
        //{
        //}
        //
        //Use TestCleanup to run code after each test has run
        //[TestCleanup()]
        //public void MyTestCleanup()
        //{
        //}
        //
        #endregion


        /// <summary>
        ///A test for GetMostFrequentlyPlayedGames
        ///</summary>
        [TestMethod()]
        public void GetMostFrequentlyPlayedGamesTest()
        {
            Game actual;
            actual = Game.GetMostFrequentlyPlayedGame();
            Assert.AreEqual("Tontolone", actual.Title);
        }

        /// <summary>
        ///A test for GetAllGames
        ///</summary>
        [TestMethod()]
        public void GetAllGamesTest()
        {
            IQueryable<Game> actual;
            actual = Game.GetAllGames();
            Assert.AreEqual(actual.Count(), 3);
        }

        /// <summary>
        ///A test for GetUserGames
        ///</summary>
        [TestMethod()]
        public void GetUserGamesTest()
        {
            User user = User.GetUserByNickname("linda");
            List<Game> actual;
            actual = Game.GetUserGames(user);
            Assert.AreEqual(actual.Count(), 2);
        }

        /// <summary>
        ///A test for GetPlayedGamesByDate
        ///</summary>
        [TestMethod()]
        public void GetPlayedGamesByDateTest()
        {
            DateTime date = new DateTime(2010, 1, 1);
            List<Game> actual = Game.GetPlayedGamesByDate(date);
            Assert.AreEqual(2, actual.Count());
        }

        /// <summary>
        ///A test for GetGameWithMaxNumberOfAnswers
        ///</summary>
        [TestMethod()]
        public void GetGameWithMaxNumberOfAnswersTest()
        {
            List<Game> actual = Game.GetGameWithMaxNumberOfAnswers();
            Assert.AreEqual(7, actual.Count);
           // Assert.Inconclusive("Verify the correctness of this test method.");
        }

        /// <summary>
        ///A test for GetSessionsWithHighestScore
        ///</summary>
        [TestMethod()]
        public void GetSessionsWithHighestScoreTest()
        {
            List<GameSession> actual = Game.GetGame(1).GetGameSessionsWithHighestScore();
            Assert.AreEqual(1000, actual.First().Score);
        }

        /// <summary>
        ///A test for GetUsersThatPlayedThisGame
        ///</summary>
        [TestMethod()]
        public void GetUsersThatPlayedThisGameTest()
        {
            Game target = Game.GetGame(1); // TODO: Initialize to an appropriate value
            List<User> actual = target.GetUsersThatPlayedThisGame();
            Assert.AreEqual(3, actual.Count);
        }

        /// <summary>
        ///A test for GetAllUserGames
        ///</summary>
        [TestMethod()]
        public void GetAllUserGamesTest()
        {
            List<Game> actual = Game.GetAllUserGames(User.GetUserByNickname ("einstein"));
            Assert.AreEqual(3, actual.Count);
           // Assert.Inconclusive("Verify the correctness of this test method.");
        }
    }
}
